import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int n = in.nextInt();
            int x = in.nextInt();
            int y = in.nextInt();
            Map<int[],Integer> map = new HashMap<>();
            long ans = 0;
            for(int i=0; i<n; i++){
                int j = in.nextInt();
                int[] a = new int[]{j%x, j%y};
                ans += map.getOrDefault(new int[]{(x-j%x)%x,j%y},0);
                System.out.println((x-j%x)%x+" "+j%y);
                map.put(a, map.getOrDefault(a,0)+1);
            }
            System.out.println(ans);
        }
    }
}
class test{
    public static void main(String[] args) {
        Map<int[],Integer> map = new HashMap<>();
    }
}